package server.startup;

import server.Lifecycle;
import server.Wrapper;
import server.connector.http.HttpConnector;
import server.core.*;
import server.deploy.FilterDef;
import server.deploy.FilterMap;

import javax.servlet.FilterConfig;
import java.util.HashMap;

public class BootStrap {
    public static void main(String[] args) {
        HttpConnector connector = new HttpConnector();


        StandardContext context = new StandardContext();
        context.setName("context_app1");

        //添加监听器
        context.addLifecycleListener(new SimpleContextConfig());

        connector.setContainer(context);
        try {
            connector.initialize();
            connector.start();
            ((Lifecycle)context).start();
            System.in.read();
            ((Lifecycle)context).stop();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }


    //    public void initial() {
//        FilterDef filterDef1 = new FilterDef();
//        filterDef1.setFilterClass("Filter1");
//        filterDef1.setFilterName("F1");
//        filterDef1.addInitParameter("f1", "k1");
//        filterDef1.addInitParameter("f2", "k2");
//
//        FilterDef filterDef2 = new FilterDef();
//        filterDef2.setFilterClass("Filter2");
//        filterDef2.setFilterName("F2");
//
//        try {
//            ApplicationFilterConfig filterConfig1 = new ApplicationFilterConfig(this, filterDef1);
//            ApplicationFilterConfig filterConfig2 = new ApplicationFilterConfig(this, filterDef2);
//            filterConfigs.put("F1", filterConfig1);
//            filterConfigs.put("F2", filterConfig2);
//        } catch (Throwable t) {
//            t.printStackTrace();
//        }
//    }
}
